<?php
require_once "../php/admin/dataSQL.php";
require_once "../php/admin/rootDB.php";
session_start();
$admin=$_SESSION['admin'];
$adminDb=new rootDB();
$id=$_GET['id'];
$time=date("Y年m月d日 H:i:s",time());
$data=$adminDb->query_idea_self($id);
$name=$data[0]['name'];
$email=$data[0]['tel'];
$time=$data[0]['addtime'];
$content=$data[0]['content'];
$examine=$data[0]['examine'];

?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../static/css/font.css">
    <link rel="stylesheet" href="../static/css/xadmin.css">
</head>
<body>
<div class="x-body layui-anim layui-anim-up">
    <fieldset class="layui-elem-field">
        <legend>用户信息</legend>
        <div class="layui-field-box">
            <table class="layui-table">
                <tbody>
                <tr>
                    <th>用户名</th>
                    <td><?php echo $name ?>

                </tr>
                <input id="card" style="display: none" value="<?php echo $id ?>">
                <input id="email" style="display: none" value="<?php echo $email ?>">
                <tr>
                    <th>邮箱</th>
                    <td><?php echo $email ?></td></tr>
                <tr>
                <tr>
                    <th>状态</th>
                    <td><?php
                        if($examine=="200"){
                            echo "审核通过";
                        }
                        else {
                            echo "审核未通过";
                        }?></td></tr>
                <tr>
                    <th>发布时间</th>
                    <td><?php echo $time ?></td></tr>
                </tbody>
            </table>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field">
        <legend>反馈/建议</legend>
        <div class="layui-col-md12">
            <div class="layui-card">

                <div class="layui-card-body">
                    <?php echo $content ?>
                </div>

            </div>
        </div>

    </fieldset>
    <fieldset class="layui-elem-field">
    <legend>审核</legend>
    <div class="layui-field-box">
        <table class="layui-table">
            <tbody>

            <tr>
                <?php
                        if($examine=="200" ||$examine=="404"){
                            echo "<td><div class=\"layui-card-header\"><button class=\"layui-btn layui-btn-disabled layui-btn-sm\">已 审 核</button> </div></td>
<td><div class=\"layui-card-header\"> <button class=\"layui-btn layui-btn-sm layui-btn-disabled\">驳 回</button></div></td>";
                        }
                        else {
                            echo "<td><div class=\"layui-card-header\"><button onclick=\"sumb()\" class=\"layui-btn  layui-btn-sm\">审 核 通 过</button> </div></td>
<td><div class=\"layui-card-header\"> <button onclick=\"reject()\" class=\"layui-btn layui-btn-sm layui-btn-danger\">驳 回</button></div></td>";
                        }?>
            </tr>
            </tbody>
        </table>
    </div>
    </fieldset>

</div>
<script type="text/javascript" src="../static/lib/layui/layui.all.js"></script>
<script type="text/javascript" src="../static/js/jquery-3.3.1.min.js"></script>
<script>
    var card=document.getElementById("card").value;
    var email=document.getElementById("email").value;
    function sumb() {


        var code=200;
        layer.confirm('是否确定通过审核？', function(index) {
            $.ajax({
                type:'post',
                cache:'false',
                url:'../php/admin/add_examine.php',
                data: {
                    id:card,
                    "code":code,
                    "email":email,
                },
                dataType:'json',
                success:function (dat) {
                    layer.msg(dat.message);

                },
                error:function () {
                    layer.msg("网络异常");
                }




            });
        });

    }
    function reject() {
        var code=404;
        layer.confirm('是否确定驳回建议？', function(index) {
            $.ajax({
                type:'post',
                cache:'false',
                url:'../php/admin/add_examine.php',
                data: {
                    id:card,
                    "code":code,
                    "email":email,
                },
                dataType:'json',
                success:function (dat) {
                    layer.msg(dat.message);
                    window.load();

                },
                error:function () {
                    layer.msg("网络异常");
                }




            });
        });
    }
</script>
</body>
</html>